import cv2
import matplotlib.pyplot as plt

from skimage import measure


# Construct some test data
from skimage.color import rgb2gray

rr = cv2.imread('../testData/images/edges/edge1.png')
rr = cv2.cvtColor(rr, cv2.COLOR_BGR2RGB)
r = rgb2gray(rr)
# Find contours at a constant value of 0.8
contours = measure.find_contours(r)
# Display the image and plot all contours found
fig, ax = plt.subplots()
ax.imshow(r, cmap=plt.cm.gray)
for contour in contours:
    ax.plot(contour[:, 1], contour[:, 0], linewidth=2)
# c0 = np.floor(contours[2][0]).astype(int)
# x = rr[209, 354]
ax.axis('image')
ax.set_xticks([])
ax.set_yticks([])
plt.show()
